#include "jiemian1.h"

#include"tui.h"

#include<QString>
jiemian1::jiemian1(QWidget *parent) : QWidget(parent)
{b.setText("重新开始");
    connect(&b,&QPushButton::released,this,&jiemian1::rechange);
    b.move(2*64,9*64);
    setWindowTitle("推箱子");
    pBox=new boxGame;
    pMap=new QPainter(this); b.setParent(this);
    setFixedSize(10*64,10*64);

  c.setParent(this);c.setText("结束");
  connect(&c,&QPushButton::released,this,&jiemian1::close);
  c.move(6*64,9*64);
}

void jiemian1::keyPressEvent(QKeyEvent *event)
{
pBox->Keydown(event);
if(pBox->gameover()){
    this->close();
}
}

void jiemian1::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
    pMap->begin(this);
    pBox->boxGame::drawmap(pMap);
    pMap->end();
    update();
}

void jiemian1::rechange()
{
    pBox=new boxGame;
    pMap=new QPainter(this);
}


